home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / util / misc / tritonrexx376.lha / TritonRexx / Programme / Exchange.rexx < prev   
OS/2 REXX Batch file  |  1995-09-17  |  13KB  |  414 lines

  1. /*
  2.    $VER: Exchange.rexx V1.0 (17.9.95) Copyright by Nils Goers
  3.  
  4.   This ARexx script was written using the tritonrexx.library and
  5.   rexxtricks.library from Juergen Kohrmeyer <j_kohrmeyer@wilam.north.de>.
  6.  
  7.   This Script needs HandleCX from Martin Berndt.
  8. */
  9.  
  10. /*  temporary Filename */
  11. Tmp.Out  = "t:HandleCX.out"
  12.  
  13. /* Name and path from Martin Berndt's 'HandleCX' */
  14. HandleCX = "HandleCX"
  15.  
  16. /************************************************
  17.  * Please don't change anything under this line *
  18.  ************************************************/
  19. NL = '0a'x
  20.  
  21. PARSE ARG PubScreen
  22.  
  23. IF PubScreen == "?" THEN DO
  24.  OPTIONS PROMPT "PUBSCREEN/K: "
  25.  PARSE PULL PubScreen
  26. END
  27.  
  28. IF PubScreen == "" THEN
  29.    PubScreen  = "Workbench"
  30.  
  31. IF ~SHOW('LIBRARIES','tritonrexx.library') THEN DO
  32.    IF ~ADDLIB('tritonrexx.library',10,-30,0) THEN DO
  33.       SAY 'Kann die <tritonrexx.library> nicht oeffnen!'
  34.       EXIT(10)
  35.    END
  36. END
  37.  
  38. IF ~SHOW('LIBRARIES','rexxtricks.library') THEN DO
  39.    IF ~ADDLIB('rexxtricks.library',10,-30,0) THEN DO
  40.       SAY 'Kann die <rexxtricks.library> nicht oeffnen!'
  41.       EXIT(10)
  42.    END
  43. END
  44.  
  45. call _CreateList
  46.  
  47. /*
  48. ** Beschreibung der Applikation
  49. */
  50.  
  51. appname     = 'Exchange'
  52. applongname = 'Exchange -  1995 by Nils Goers'
  53. appinfo     = 'Tool for Commodity controlling'
  54. appversion  = '1.0'
  55. apprelease  = '1'
  56. appdate     = '17.9.95'
  57.  
  58. Activation.0 = 2
  59. Activation.1 = "[a]ctive"
  60. Activation.2 = "in[a]ctive"
  61.  
  62. Activation2.0 = 2
  63. Activation2.1 = "Deact[i]vate all"
  64. Activation2.2 = "Act[i]vate all"
  65.  
  66. IF active.1 == "INACTIVE" THEN N1 = 1
  67.  
  68. _maintags:
  69. windowtags = WindowID(1),
  70.              PubScreenName(PubScreen),
  71.              WindowTitle(appname appversion),
  72.                         BeginMenu("Project"),
  73.                         MenuItem("A_About",10),
  74.                         MenuItem("About Triton",11) ItemBarlabel,
  75.                         MenuItem("U_Update Toollist",12),
  76.                         MenuItem("P_Update PubScreen",14) ItemBarlabel,
  77.                         MenuItem("Q_Quit",13),
  78.              'HorizGroupA Space VertGroupA Space',
  79.                 NamedSeparatorIN("Available _commodities",1),
  80.                'Space',
  81.                ListSS('Tools',1,0,0),
  82.               'EndGroup',
  83.               'VertGroupA SpaceB SpaceB',
  84.               GetEntryButton(12) 'SpaceB SpaceB SpaceB SpaceB SpaceB SpaceB SpaceB SpaceB',
  85.               'EndGroup',
  86.               'SpaceS',
  87.               'VertGroupA Space',
  88.                 NamedSeparator("Informations"),
  89.                 'Space',
  90.                'TROB_FrameBox TRFB_Text',
  91.                 'VertGroupA',
  92.                 'SpaceS',
  93.                  ClippedTextID(Information.1,2),
  94.                  ClippedTextID(Information2.1,22),
  95.                 'Space EndGroup',
  96.                'SpaceB',
  97.                'BeginLine',
  98.                Button("_Show Window",3),
  99.                'SpaceS',
  100.                Button("_Hide Window",4),
  101.                'EndLine',
  102.               'SpaceS',
  103.                'BeginLine',
  104.                  CycleGadget(activation,n1,5),
  105.                  'SpaceS',
  106.                  Button("    _Remove   ",6),
  107.                'EndLine',
  108.                'SpaceS',
  109.                'BeginLine',
  110.                  CycleGadget(activation2,0,7),
  111.                  'SpaceS',
  112.                  Button("     Remove all    ",8),
  113.                'EndLine',
  114.               'Space EndGroup Space EndGroup EndProject'
  115.  
  116. /*
  117. ** Unterbrechungssignale
  118. */
  119.  
  120. SIGNAL ON break_c
  121. SIGNAL ON failure
  122. SIGNAL ON halt
  123. SIGNAL ON ioerr
  124. SIGNAL ON syntax
  125.  
  126. app = TR_CREATEAPP('TRCA_Name'     '"'appname'"',
  127.                    'TRCA_LongName' '"'applongname'"',
  128.                    'TRCA_Info'     '"'appinfo'"',
  129.                    'TRCA_Version'  '"'appversion'"',
  130.                    'TRCA_Release'  '"'apprelease'"',
  131.                    'TRCA_Date'     '"'appdate'"',
  132.                    'TAG_END')
  133.  
  134. IF app ~= '00000000'x THEN DO
  135.  
  136.    window = TR_OPENPROJECT(app,windowtags)
  137.    WindowProject=C2D(window) /* zum Locken des Fensters bei About */
  138.  
  139.    IF window ~= '00000000'x THEN DO
  140.       ende = 0
  141.  
  142. IF GUI.1 == "NOGUI" THEN DO
  143.   CALL TR_SETATTRIBUTE(window,3,'TRAT_Disabled',1)
  144.   CALL TR_SETATTRIBUTE(window,4,'TRAT_Disabled',1)
  145. END
  146.       DO WHILE ende ~= 1
  147.          CALL TR_WAIT(app,'')
  148. /* 1 = ListView
  149.    3 = ShowWindow
  150.    4 = HideWindow
  151.    5 = Cycle 1
  152.    6 = Remove
  153.    7 = Cycle 2
  154.    8 = Remove all
  155.   10 = About
  156.   11 = About Triton
  157.   12 = Update
  158.   13 = Quit
  159.   14 = Update Screen
  160. */
  161.    
  162.          DO WHILE TR_HANDLEMSG(app,'event')
  163.           IF event.trm_class = 'TRMS_KEYPRESSED' THEN DO
  164.            IF event.trm_code == 32 THEN CALL _InActivate
  165.            IF event.trm_code == 23 THEN DO
  166.             nummer = TR_GETATTRIBUTE(window,7,'TRAT_Value')
  167.              IF Nummer == 0 THEN 
  168.                CALL TR_SETATTRIBUTE(window,7,'TRAT_Value',1)
  169.               ELSE
  170.                CALL TR_SETATTRIBUTE(window,7,'TRAT_Value',0)
  171.            CALL _InActivateALL
  172.            END
  173.           END
  174.  
  175.           IF event.trm_class = 'TRMS_ACTION' THEN DO
  176.             nummer = TR_GETATTRIBUTE(window,1,'TRAT_Value')+1
  177.            SELECT
  178.              WHEN event.trm_id = 3 THEN
  179.                ADDRESS COMMAND HandleCX '"'tools.nummer'"' 'POPUP'
  180.              WHEN event.trm_id = 4 THEN
  181.                ADDRESS COMMAND HandleCX '"'tools.nummer'"' 'HIDE'
  182.              WHEN event.trm_id = 6 THEN DO
  183.                ADDRESS COMMAND HandleCX '"'tools.nummer'"' 'REMOVE'
  184.                 CALL _CreateList
  185.                 CALL TR_SETATTRIBUTE(window,1,'TROB_Listview',Tools)
  186.                 nummer = TR_GETATTRIBUTE(window,1,'TRAT_Value')+1
  187.                 CALL TR_SETATTRIBUTE(window,2,'TRAT_Text',Information.nummer)
  188.                 CALL TR_SETATTRIBUTE(window,22,'TRAT_Text',Information2.nummer)
  189.                 call _CheckGUI
  190.                 call _CheckActive
  191.              END
  192.              WHEN event.trm_id = 8 THEN DO
  193.               DO i = 1 to tools.0
  194.                    ADDRESS COMMAND HandleCX '"'Tools.i'"' 'REMOVE'
  195.               END
  196.                    CALL _CreateList
  197.                    CALL TR_SETATTRIBUTE(window,1,'TROB_Listview',Tools)
  198.                    CALL _CheckGUI
  199.                    CALL _CheckActive
  200.              END
  201.                   WHEN event.trm_id = 10 THEN DO
  202.                    CALL TR_EasyRequest(app,"Exchange.rexx V1.0 (17.9.95)",
  203.                    NL NL"(c) 1995 Nils Goers <N.Goers@Art-Line.Art-Line.de>",
  204.                    NL"- freely distributable -","OK","TREZ_Title About TREZ_LockProject" WindowProject)
  205.                   END
  206.  
  207.                   WHEN event.trm_id = 11 THEN DO
  208.                    CALL TR_EasyRequest(app,"This application uses the Triton GUI creation system",
  209.                    NL"Triton is (C) by Stefan Zeiger <s.zeiger@laren.rhein-main.de>",
  210.                 NL NL"This application was written using the tritonrexx.library",
  211.                    NL"tritonrexx.library is (C) by Juergen Kohrmeyer <j_kohrmeyer@wilam.north.de>",,
  212.                    "OK","TREZ_Title" '"About Triton"' "TREZ_LockProject" WindowProject)
  213.                   END
  214.  
  215.                   WHEN event.trm_id = 12 THEN DO
  216.                    CALL _CreateList
  217.                    CALL _CheckGUI
  218.                    CALL _CheckActive
  219.                    CALL TR_SETATTRIBUTE(window,1,'TROB_Listview',Tools)
  220.                    CALL TR_SETATTRIBUTE(window,1,'TRAT_Value',Nummer-1)
  221.                    CALL TR_SETATTRIBUTE(window,2,'TRAT_Text',Information.nummer)
  222.                    CALL TR_SETATTRIBUTE(window,22,'TRAT_Text',Information2.nummer)
  223.                   END
  224.  
  225.                   WHEN event.trm_id = 14 THEN CALL _NewPubScreen
  226.                   WHEN event.trm_id = 13 THEN DO
  227.                    Quit=TR_EasyRequest(app,"Really Quit?",,
  228.                                       "_Yes|_No","TREZ_Title Quit TREZ_LockProject" WindowProject)
  229.                     IF Quit == 1 THEN DO
  230.                      CALL TR_CLOSEPROJECT(window)
  231.                      CALL TR_DELETEAPP(app)
  232.                      EXIT(0)
  233.                     END
  234.                   END
  235.             OTHERWISE
  236.             NOP
  237.            END
  238.           END
  239.  
  240.             IF event.trm_class = 'TRMS_NEWVALUE' THEN DO
  241.                SELECT
  242.                   WHEN event.trm_id = 1 THEN DO
  243.                      nummer = event.trm_data+1
  244.                       CALL TR_SETATTRIBUTE(window,2,'TRAT_Text',Information.nummer)
  245.                       CALL TR_SETATTRIBUTE(window,22,'TRAT_Text',Information2.nummer)
  246.                       call _CheckGUI
  247.                       call _CheckActive
  248.                   END
  249.                   WHEN event.trm_id = 5 THEN CALL _InActivate
  250.  
  251.                   WHEN event.trm_id = 7 THEN CALL _InActivateALL
  252.                   OTHERWISE
  253.                      NOP
  254.                END
  255.             END
  256.  
  257.             IF event.trm_class = 'TRMS_CLOSEWINDOW' THEN  ende = 1
  258.          END
  259.       END
  260.  
  261.       CALL TR_CLOSEPROJECT(window)
  262.    END
  263.  
  264.    CALL TR_DELETEAPP(app)
  265. END
  266.  
  267. EXIT(0)
  268.  
  269. _CreateList:
  270. ADDRESS COMMAND HandleCX "v >"Tmp.out
  271. IF READFILE(Tmp.Out,Infile) == 0 THEN EXIT(5)
  272.  
  273. Tools.0 = Infile.0/2
  274. Information.0 = Tools.0
  275. Information2.0 = Tools.0
  276. Active.0 = Tools.0
  277. GUI.0 = Tools.0
  278. j = 1
  279.  
  280. DO i = 1 TO Infile.0
  281.  /* hier wird alles in die richtigen Listen verteilt,
  282.     Toolname, Active, Gui */
  283.  Tools.j=DELWORD(Infile.i,1,1)
  284.  WordNo=WORDS(Tools.j)
  285.  GUI.j = SUBWORD(Tools.j,WordNo); Active.j = SUBWORD(Tools.j,WordNo-1,1)
  286.  Tools.j = SUBWORD(Tools.j,1,WordNo-2)
  287.  
  288.  /* und hier wird die Information zu dem Commodity verarbeitet */
  289.  i = i+1
  290.  Information.j=DELWORD(Infile.i,1,1)
  291.   MaxLenght=LENGTH(Information.j); Position=LASTPOS(" (",Information.j)
  292.  First=LEFT(Information.j,Position)
  293.  second=RIGHT(Information.j,Maxlenght-Position-1); second=LEFT(second,Maxlenght-Position-2)
  294.  Information.j = First
  295.  Information2.j = second
  296.  j=j+1
  297. END
  298.  
  299. ADDRESS COMMAND "c:delete" Tmp.Out "QUIET"
  300. RETURN
  301.  
  302. _CheckGUI:
  303.  IF gui.nummer == "NOGUI" THEN DO
  304.   CALL TR_SETATTRIBUTE(window,3,'TRAT_Disabled',1)
  305.   CALL TR_SETATTRIBUTE(window,4,'TRAT_Disabled',1)
  306.  END
  307.  ELSE DO
  308.   CALL TR_SETATTRIBUTE(window,3,'TRAT_Disabled',0)
  309.   CALL TR_SETATTRIBUTE(window,4,'TRAT_Disabled',0)
  310.  END
  311. RETURN
  312.  
  313. _CheckActive:
  314.  IF active.nummer == "INACTIVE" THEN
  315.   CALL TR_SETATTRIBUTE(window,5,'TRAT_Value',1)
  316.  ELSE
  317.   CALL TR_SETATTRIBUTE(window,5,'TRAT_Value',0)
  318. RETURN
  319.  
  320. _InActivate:
  321.   nummer = TR_GETATTRIBUTE(window,1,'TRAT_Value')+1
  322.   ADDRESS COMMAND HandleCX '"'Tools.Nummer'"' 'TOGGLE'
  323.   CALL _CreateList
  324.   CALL TR_SETATTRIBUTE(window,1,'TROB_Listview',Tools)
  325.   CALL _CheckGUI
  326.   CALL _CheckActive
  327. RETURN
  328.  
  329. _InActivateALL:
  330.   nummer = TR_GETATTRIBUTE(window,7,'TRAT_Value')
  331.   IF nummer == 1 THEN Action = 'Disable'
  332.   ELSE Action = 'Enable'
  333.   DO i = 1 to tools.0
  334.   ADDRESS COMMAND HandleCX '"'tools.i'"' Action
  335.   END
  336.   CALL _CreateList
  337.   CALL TR_SETATTRIBUTE(window,1,'TROB_Listview',Tools)
  338.   CALL _CheckGUI
  339.   CALL _CheckActive
  340. RETURN
  341.  
  342. /*  Routine, die das GUI auf einem neuen PubScreen oeffnen laesst */
  343. _NewPubScreen:
  344. IF PUBSCREENLIST('ScreenList') == 0 THEN RETURN
  345.  
  346. ScreenListTags = WindowID(2),
  347.    WindowPosition('TRWP_MOUSEPOINTER'),
  348.    WindowTitle('Change PubScreen'),
  349.    WindowFlags('TRWF_NOCLOSEGADGET|TRWF_NOESCCLOSE'),
  350.    PubScreenName(Pubscreen),
  351.    'VertGroupA',
  352.       'Space',
  353.       'HorizGroupA',
  354.          'Space',
  355.          ListSel('screenlist',301,0),
  356.          'Space',
  357.       'EndGroup',
  358.       'Space',
  359.       'HorizSeparator',
  360.       'Space',
  361.       'HorizGroupA',
  362.       'Space',
  363.       ButtonRE('Cancel',302),
  364.       'Space',
  365.    'EndGroup Space EndGroup EndGroup EndProject'
  366.  
  367.     PubScreenProject = TR_OPENPROJECT(app,Screenlisttags)
  368.  
  369.   IF PubScreenProject ~= '00000000'x THEN DO
  370.     CALL TR_LOCKPROJECT(window)
  371.  
  372.       DO WHILE ende ~= 1
  373.          DO WHILE TR_HANDLEMSG(app,'event2')
  374.             IF event2.trm_class = 'TRMS_ACTION' THEN ende = 1 /* Cancel Gadget */
  375.  
  376.             IF event2.trm_class = 'TRMS_NEWVALUE' THEN DO
  377.             nummer = TR_GETATTRIBUTE(PubScreenProject,301,'TRAT_Value')+1
  378.              IF PubScreen ~= Screenlist.nummer THEN DO
  379.               PubScreen = ScreenList.nummer
  380.               CALL TR_UNLOCKPROJECT(window)
  381.               CALL TR_CLOSEPROJECT(PubScreenProject)
  382.               CALL TR_CLOSEPROJECT(window)
  383.               CALL TR_DELETEAPP(app)
  384.               CALL _maintags
  385.              END
  386.             ELSE ende = 1
  387.             END
  388.          END
  389.       END
  390.  
  391.    ende = 0
  392.     CALL TR_UNLOCKPROJECT(window)
  393.     CALL TR_CLOSEPROJECT(PubScreenProject)
  394. END
  395. RETURN
  396.  
  397. /*******************************************************************************
  398. ** Routine, die bei einer Unterbrechung des Scripts aufgerufen wird
  399. *******************************************************************************/
  400.  
  401. break_c:
  402. failure:
  403. halt:
  404. ioerr:
  405. syntax:
  406.    SAY '+++ Fehler' rc 'in Zeile' sigl '-' ERRORTEXT(rc)
  407.    SAY SOURCELINE(sigl)
  408.  
  409.    IF app ~= '00000000'x THEN
  410.       CALL TR_DELETEAPP(app)
  411.  
  412.    EXIT(10)
  413. /*EOS*/
  414.